package sk.stuba.fiit.foo07.genex.dao;

import java.sql.SQLException;
import java.util.ArrayList;

import sk.stuba.fiit.foo07.genex.beans.Category;
import sk.stuba.fiit.foo07.genex.beans.Question;
import sk.stuba.fiit.foo07.genex.exceptions.QuestionInTestException;

/**
 * 
 * @author _mizu_
 * 
 */
public interface QuestionDao {

    /**
     * Method for getting questions by their ID.
     * 
     * @param questionID
     *                id of question
     * 
     * @return question
     * 
     */
    public Question getQuestionByID(Integer questionID) throws SQLException;

    /**
     * Method for getting questions by their ID.
     * 
     * @param questionIDs
     *                id of questions
     * 
     * @return lits of questions
     * 
     */
    public ArrayList<Question> getQuestionsByIDs(ArrayList<Integer> questionIDs)
            throws SQLException;

    /**
     * Method for getting question in a category.
     * 
     * @param categoryID
     *                id of category
     * 
     * @return list of questions
     * 
     */
    public ArrayList<Question> getQuestionsByCategoryID(Integer categoryID)
            throws SQLException;

    /**
     * Method for getting questions in a test.
     * 
     * @param testID
     *                id of test
     * 
     * @return list of questions
     * 
     */
    public ArrayList<Question> getQuestionsByTestID(Integer testID)
            throws SQLException;

    /**
     * Method for adding questions.
     * 
     * @param categoryID
     *                id of category
     * @param toAdd
     *                question to add
     * 
     * 
     */
    public void addQuestion(Integer categoryID, Question toAdd)
            throws SQLException;

    /**
     * Method for creating a question.
     * 
     * @param toCreate
     *                question from which a question is being created
     * 
     * 
     * 
     */
    public void createQuestion(Question toCreate) throws SQLException;

    /**
     * Method for adding questions.
     * 
     * @param categoryID
     *                id of category
     * @param toAdd
     *                list of questions to add
     * 
     * 
     */
    public void addQuestions(Integer categoryID, ArrayList<Question> toAdd)
            throws SQLException;

    /**
     * Method for updating questions.
     * 
     * @param questionID
     *                id of question
     * @param toUpdate
     *                updated data
     * 
     * 
     * 
     */
    public void updateQuestion(Integer questionID, Question toUpdate)
            throws SQLException;

    /**
     * Method for deleting quesitons.
     * 
     * @param toDelete
     *                question which is being deleted
     * 
     * 
     * 
     */
    public void deleteQuestion(Question toDelete)
            throws QuestionInTestException, SQLException;

    /**
     * Method for deleting quesitons.
     * 
     * @param toDelete
     *                list of questions which is being deleted
     * 
     * 
     * 
     */

    public void deleteQuestions(ArrayList<Question> toDelete)
            throws QuestionInTestException, SQLException;

    /**
     * Method for deleteing question from a specific categry.
     * 
     * @param toDelete
     *                question for deleting
     * @param from
     *                category from which to delete
     * @return answer
     * 
     */
    public void deleteQuestionFromCategory(Question toDelete, Category from)
            throws SQLException;

    /**
     * Moves question between two categories
     * 
     * @param fromCategoryID
     * @param toCategoryID
     */
    public void moveQuestion(Question q, Integer fromCategoryID,
            Integer toCategoryID) throws SQLException;

    /**
     * Method for copying questions questions.
     * 
     * @param questionID
     *                id of question which s being copied
     * @param toCategoryID
     *                id of the destination category
     * @return answer
     * 
     */
    public void copyQuestion(int questionID, Integer toCategoryID)
            throws SQLException;

    /**
     * This method returns set of questions that meets the constraints defined
     * by input parameters
     * 
     * @param questionCategoryIDs
     *                List of question category IDs for the test
     * @param keywordIDs
     *                List of question keyword IDs for the test
     * @param questionTypeIDs
     *                List of question type IDs for the test
     * @param containsPictures
     *                If false the test must not contain questions with pictures
     * @param difficulty
     * @return
     * @throws SQLException
     */
    public ArrayList<Integer> getQuestionsForTestGenerator(
            ArrayList<Integer> questionCategoryIDs,
            ArrayList<Integer> keywordIDs, ArrayList<Integer> questionTypeIDs,
            boolean containsPictures, Integer difficulty) throws SQLException;

    /**
     * Returns number of questions in given category.
     * 
     * @param categoryID
     * @return
     */
    public int getQuestionCount(Integer categoryID) throws SQLException;
}
